package com.huyn.baseframework.statesync.model;

import java.io.Serializable;

/**
 * Created by huyn on 2015/6/5.
 */
public class BaseSyncState implements Serializable {

    public String id;
    public boolean favored;
    public int pos;
    public int favorNum;

    public BaseSyncState(String id, boolean state, int pos, int favorNum) {
        this.id = id;
        this.favored = state;
        this.pos = pos;
        this.favorNum = favorNum;
    }

    public void changeState() {
        this.favored = !favored;

        if(favored)
            favorNum++;
        else
            favorNum--;
        if(favorNum < 0)
            favorNum = 0;
    }

    public void updateIndex(int index) {
        this.pos = index;
    }

    public void updateState(boolean state) {
        this.favored = state;
    }

    public void updateFavorNum(int num){
        this.favorNum = num;
    }
}
